Page({
  data:{
    needArray: ["云主机弹性计算", "云存储服务", "网络负载均衡", "云数据库", "云安全", "云监控", "云VPN网络"],
    indexNeed: 0,
    needs: '云主机弹性计算',
    name:'',
    phone: '',
    city: '',
    company: '',
    requirement: ''
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  bindNeedchange (e) {
     this.setData({
          needs: this.data.needArray[e.detail.value]
      });
  },
  submitForm () {
    var mobileReg = /^1[34578]\d{9}$/;
    //var phoneReg = /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/;
    var _this = this;
    if(_this.data.name == ""){
        wx.showModal({
            title: "提示",
            content: "请输入您的姓名",
            showCancel: false,
            confirmText: "确定",
        });
        return false;
    }
    if(_this.data.phone == "" || !mobileReg.test(_this.data.phone)){
        wx.showModal({
            title: "提示",
            content: "请正确输入手机号码",
            showCancel: false,
            confirmText: "确定",
        });
        return false;
    }
    if(_this.data.city == ""){
        wx.showModal({
            title: "提示",
            content: "请输入所在地市",
            showCancel: false,
            confirmText: "确定",
        });
        return false;
    }
     if(_this.data.company == ""){
        wx.showModal({
            title: "提示",
            content: "请输入所在单位名称",
            showCancel: false,
            confirmText: "确定",
        });
        return false;
    }
    if(_this.data.requirement == ""){
        wx.showModal({
            title: "提示",
            content: "请输入您的需求内容",
            showCancel: false,
            confirmText: "确定",
        });
        return false;
    }
  },
  getName (e) {
    this.setData({
      name: e.detail.value
    })
  },
  getPhone (e) {
    this.setData({
      phone: e.detail.value
    })
  },
  getCity (e) {
    this.setData({
      city: e.detail.value
    })
  },
  getCompany (e) {
    this.setData({
      company: e.detail.value
    })
  },
  getRequirement (e) {
     this.setData({
      requirement: e.detail.value
    })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})